#include "mainclass.h"

#include <QCoreApplication>
#include <QStringList>
#include <QTextStream>

MainClass::MainClass(QObject *parent) : QObject(parent) {
}

void showHelp();

void MainClass::run() {
    QStringList arguments = QCoreApplication::arguments();

    // removing application path:
    arguments.removeAt(0);

    // checking for no commands:
    if (arguments.isEmpty()) {
        showHelp();
        emit finished();
    }

    // checking for every supported command:
    QString command = arguments.takeFirst();
    if (command == "h" || command == "help") {
        showHelp();
        emit finished();
    }

    emit finished();

}

void showHelp() {
    QTextStream out(stdout);
    out << "this is Long Haul\n";
}
